
FROM frolvlad/alpine-glibc
USER root

ENV CONDA_INSTALL_SH Miniconda3-py39_4.9.2-Linux-x86_64.sh
ENV PATH /bin:/sbin:/usr/bin:/opt/miniconda/bin
ENV NOTEBOOK_ROOT /notebook

# put your package at here
ENV PYTHONPATH $NOTEBOOK_ROOT/lib
# change login password at here
ENV PASSWORD 'coolyaolei'

ENV KITE_INSTALL_FILE https://linux.kite.com/linux/current/kite-installer

# ADD winfont /usr/share/fonts/winfonts
# ADD jetbrainsmono /usr/share/fonts/jetbrainsmono

# 北外的conda源，清华源现在有点慢
ADD .condarc /root/.condarc
# Change mirror site For China
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories && \
    apk update && \
    apk add --no-cache openssl tini bash libstdc++ font-adobe-100dpi && \
    cd /usr/share/fonts && fc-cache -f && cd /root && \
    wget -q https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/$CONDA_INSTALL_SH && \
    sh /root/$CONDA_INSTALL_SH -b -p /opt/miniconda && \
    rm -f $CONDA_INSTALL_SH && \
    mkdir -p /notebook && \
    # 清除缓存，升级conda
    conda clean -i && \
    conda update --all && \
    # 升级base环境中软件
    conda update -n base -c defaults conda -y && \
    # 设置pip源
    pip config set global.index-url https://opentuna.cn/pypi/web/simple && \
    # 安装python包
    conda install -c conda-forge pandas datatable h5py dask xlrd xlwt openpyxl selenium mysql-connector-python pymongo \
    mongoengine sqlalchemy flask bokeh dash jupyter-dash plotly autopep8 yapf jupyterlab jupyter-archive arrow maya voila\
    # nodejs用conda装比较好，apt装的包，jupyter总报错
    nodejs -y && \
    # conda没有的包，用pip装
    pip install xeus-python chart_studio psycopg2-binary cufflinks plotly-express echarts-python dash_bootstrap_components whenpy && \
    # 安装代码自动补全，kite
    wget -q -O ./kite-installer https://linux.kite.com/linux/current/kite-installer && \
    chmod 755 ./kite-installer && \
    ./kite-installer install && \
    pip install jupyter-kite && \
    rm ./kite-installer && \
    # 安装中文语言包(中文包还未正式发布,离线安装)
    wget -q https://jfds-1252952517.cos.ap-chengdu.myqcloud.com/jupyterhub/jupyterlab_language_pack_zh_CN-0.0.1.dev0-py2.py3-none-any.whl && \
    pip install ./jupyterlab_language_pack_zh_CN-0.0.1.dev0-py2.py3-none-any.whl && \
    rm -f ./jupyterlab_language_pack_zh_CN-0.0.1.dev0-py2.py3-none-any.whl && \
    #######################################################################
    # 创建配置文件
    jupyter-lab --generate-config --allow-root && \
    # #######################################################################
    # # 以下插件均亲测安装成功
    # draw.io插件
    jupyter-labextension install jupyterlab-drawio && \
    # plotly插件 
    jupyter-labextension install jupyterlab-plotly && \
    jupyter-labextension install jupyterlab-chart-editor && \
    # dash 显示插件
    jupyter-labextension install jupyterlab-dash && \
    # geojson查看
    jupyter labextension install @jupyterlab/geojson-extension && \
    # # excel,csv,ods查看
    jupyter-labextension install jupyterlab-spreadsheet && \
    #######################################################################
    export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

VOLUME ["/notebook"]
EXPOSE 8888
ENTRYPOINT [ "/sbin/tini", "--" ]
CMD jupyter-lab \
    --allow-root \
    --no-browser \
    --notebook-dir=/notebook \
    --ip=0.0.0.0  \
    --ServerApp.password=`python -c "from jupyter_server.auth import passwd; print(passwd('$PASSWORD'),end='')"`